﻿Public Class JQMyAssistant
    Inherits JQAssistant
    '
    Private _AuxSB As New StringBuilder
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="fJQ"></param>
    ''' <remarks></remarks>
    Public Sub New(ByRef fJQ As JQuery)
        MyBase.New(fJQ)
    End Sub
#Region "Make"
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="fPanel"></param>
    ''' <remarks></remarks>
    Public Sub MakePanelDraggable(ByVal fPanel As System.Web.UI.WebControls.Panel)
        _J.S("#" & fPanel.ClientID).draggable()
    End Sub
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="fTextBox"></param>
    ''' <remarks></remarks>
    Public Sub MakeDatePicker(ByVal fTextBox As System.Web.UI.WebControls.TextBox)

        _J.AddScriptSRC("/JQueryScripts/ui/i18n/ui.datepicker-es.js")
        '
        _J.AddStyle_UIAllCss()
        _J.AddStyleSRC("/JQueryScripts/jquery-ui-themeroller/ui.core.css")
        _J.AddStyleSRC("/JQueryScripts/jquery-ui-themeroller/ui.datepicker.css")
        '
        _J.S("#" & fTextBox.ClientID).datepicker("\\$.datepicker.regional['es']")
    End Sub
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="fIDDiv"></param>
    ''' <remarks></remarks>
    Public Sub MakeAccordion(ByVal fIDElement As String)
        _J.AddStyle_UIAllCss()
        _J.S("#" & fIDElement & "").accordion("\\{ header: ""h3"" }")
    End Sub
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="fIDDiv"></param>
    ''' <remarks></remarks>
    Public Sub MakeTabs(ByVal fPanel As System.Web.UI.WebControls.Panel)
        Me.MakeTabs(fPanel.ClientID)
    End Sub
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="fIDDiv"></param>
    ''' <remarks></remarks>
    Public Sub MakeTabs(ByVal fIDDiv As String)
        _J.AddStyle_UIAllCss()
        _J.S("#" & fIDDiv).tabs()
    End Sub
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="fIDElement"></param>
    ''' <param name="fsText"></param>
    ''' <remarks></remarks>
    Public Sub MakeDialog(ByVal fIDElement As String, ByVal fsText As String)
        _J.AddStyle_UIAllCss()
        '
        Me.SetHTML(fIDElement, fsText)
        _J.S("#" & fIDElement).dialog()
    End Sub
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="fIDDiv"></param>
    ''' <remarks></remarks>
    Public Sub MakeDialog(ByVal fPanel As System.Web.UI.WebControls.Panel, ByVal fsText As String)
        Me.MakeDialog(fPanel.ClientID, fsText)
    End Sub
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="fIDElement"></param>
    ''' <param name="fsText"></param>
    ''' <remarks></remarks>
    Public Sub MakeDialogModal(ByVal fIDElement As String, ByVal fsText As String)
        _J.AddStyle_UIAllCss()
        '
        Dim opts As String
        opts = JQUtils.GetOptions("position", "['left','top']", "bgiframe", "true", "height", "140", "modal", "true", "overlay", "{backgroundColor:  '#000',	opacity: 0.5} ")
        Me.SetHTML(fIDElement, fsText)
        _J.S("#" & fIDElement).dialog(opts)
        ''
    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="fIDDiv"></param>
    ''' <remarks></remarks>
    Public Sub MakeDialogModal(ByVal fPanel As System.Web.UI.WebControls.Panel, ByVal fsText As String)
        Me.MakeDialogModal(fPanel.ClientID, fsText)
    End Sub
#End Region
#Region "Dialog Confirm"
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="fIDElement"></param>
    ''' <param name="cmdActionText"></param>
    ''' <param name="cmdActionJQCode"></param>
    ''' <param name="cmdCancelText"></param>
    ''' <param name="cmdCancelJQCode"></param>
    ''' <remarks></remarks>
    Public Function MakeDialogConfirm(ByVal fIDElement As String, ByVal cmdActionText As String, ByVal cmdActionJQCode As String, ByVal cmdCancelText As String, ByVal cmdCancelJQCode As String) As String
        Dim dbuttons As String
        dbuttons = JQUtils.GetOptions("'" & cmdActionText & "'", "function(){" & cmdActionJQCode & "}", "'" & cmdCancelText & "'", "function(){" & cmdCancelJQCode & "}")
        Return Me.MakeDialogConfirm(fIDElement, dbuttons)
    End Function
    '
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="fIDElement"></param>
    ''' <param name="fsText"></param>
    ''' <remarks></remarks>
    Protected Function MakeDialogConfirm(ByVal fIDElement As String, ByVal fbuttons As String) As String
        Me.Reset_AuxSB()
        '
        _J.AddStyleSRC("/JQueryScripts/jquery-ui-themeroller/ui.all.css")
        '
        Dim dopts As String
        dopts = JQUtils.GetOptions("position", "['left','top']", "autoOpen", "false", "bgiframe", "true", "modal", "true", "overlay", "{backgroundColor:  '#000',	opacity: 0.5} ", _
                                 "buttons", fbuttons)
        '
        Me.Add(_J.S("#" & fIDElement).dialog(dopts))
        ''
        Return AuxSB()
        ''
    End Function
#End Region
#Region "AUXSB"
    '''
    '''  <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub Reset_AuxSB()
        _AuxSB = New StringBuilder
    End Sub
    Private Sub Add(ByVal fsText As String)
        _AuxSB.Append(fsText)
    End Sub
    '
    Private ReadOnly Property AuxSB()
        Get
            Return Me._AuxSB.ToString
        End Get
    End Property
    '
#End Region
End Class
